home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / KBD_UTL / TPINKEY / INKEY.ASM next >
Assembly Source File  |  1995-01-19  |  2KB  |  56 lines

  1. ;  Inkey by Peter Zicari, 1992; all rights reserved.
  2. ;
  3. ;  no fee is requested for use of this code, but I accept no liability for
  4. ;  problems that might arise from your use of it.
  5. ;  If you find it useful or find a bug and want to comment, you can contact
  6. ;  me at peter.zicari@pcohio.com
  7. ;
  8. ;
  9. ; keyboard reader that reads unrecognized key combinations replaces BP's
  10. ; readkey. The function returns key code and sets two global variables,
  11. ; Functn, which identifies the returned code as a non-letter key, and Escape. 
  12. ; The two must be declared either in the same unit or as a global variable.
  13. ; The function must be declared in a unit or used with {F+}
  14. ; The function works by calling BIOS function 10H, which was not available
  15. ; before about 1985. Using this function in your program provides the 
  16. ; key combinations without need to load ANSI with the /X paramater.
  17.  
  18. DATA segment byte public
  19.      Assume  DS:DATA
  20.      Extrn   Functn:Byte
  21.      Extrn   Escape:Byte   ;defined in unit
  22. DATA ends
  23. CODE segment
  24. ;
  25. assume cs:CODE
  26. INKEY PROC FAR
  27. PUBLIC Inkey                 ;
  28. PUSH BX                      ;
  29. MOV BL, 224                   ; BL now contains E0h, 224.
  30. XOR AX,AX                    ; zero AX
  31. MOV Functn,AH                ; set Functn to 0
  32. MOV Escape,AH                ; set Escape to 0
  33. MOV AH,10H                   ; request new keyboard function
  34. INT 16H                      ; execute interrupt. results return in AX
  35. CMP AL,0                     ; 0 is function key,
  36. JE Fun                       ; proceed with funtion if it is.
  37. CMP AL,BL                    ; if not 0 is it 224? (from odd keys).
  38. JNE Endfun                   ; skip to chars if it's not.
  39. Fun:
  40. MOV AL,AH                    ; if it is function, AH holds right data
  41. MOV AH,1                     ; 1=true
  42. MOV Functn,AH                ; Function = true
  43. JMP the_end
  44. Endfun:                      ; begin checking character : missing
  45. CMP AL,1BH                   ; is it Escape?
  46. jne the_end                  ; if not, exit, leaving char in AL.
  47. MOV Escape,AH                ; if it is, exit, leaving 1 in escape
  48. ;
  49. the_end:
  50. POP BX
  51. RET
  52. Inkey ENDP
  53. CODE ENDS
  54. END
  55.  
  56.